package cn.dliyy.base.service;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.dliyy.base.dao.HQL;
import cn.dliyy.warehouse.bean.BUnit;
import cn.dliyy.warehouse.dao.EntityDao;

@Service
public class CommonService {
  @Resource
  protected EntityDao entityDao;
  @Resource
  protected HQL hql;

  public List<?> getList(Class<?> clazz) {
    List<Object> list = entityDao.createQuery(hql.getListHQL(clazz));
    return list;
  }

  public List<?> getList(Class<?> clazz, int start, int length) {
    List<Object> list = entityDao.createQuery(hql.getListHQL(clazz), start, length);
    return list;
  }

  public void save(Object model) {
    entityDao.save(model);
  }

  public void update(Object model) {
    entityDao.update(model);
  }

  public void delete(Object model) {
    entityDao.delete(model);
  }

  public Object get(Class<?> clazz, Serializable primaryKey) {
    return entityDao.get(clazz, primaryKey);
  }

  public Object get(Class<?> clazz, String primaryKey) {
    return entityDao.get(clazz, primaryKey);
  }
}
